import { Provide } from "@midwayjs/core/dist";
import { InjectEntityModel } from "@midwayjs/typeorm";
import { UserEntity } from "../entity/user.entity";
import { Repository } from "typeorm";

@Provide()
export class UserMapper {
  @InjectEntityModel(UserEntity)
  userMapper: Repository<UserEntity>;

  async getUserByUserName(username: string) {
    return await this.userMapper.findOne({
      where: {
        username,
      },
    });
  }
}
